f8ea33
@@ -22,12 +22,14 @@
 import java.net.URI;
 import java.util.BitSet;
 import java.util.List;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 
+import org.apache.hadoop.util.Shell;
+
+
 /**
  * Collection of file manipulation utilities common across Hive.
  */
@@ -127,6 +129,12 @@
public static String makePartName(List<String> partCols, List<String> vals,
   // won't be corrupt, because the full path name in metastore is stored.
   // In that case, Hive will continue to read the old data, but when it creates
   // new partitions, it will use new names.
+  // edit : There are some use cases for which adding new chars does not seem
+  // to be backward compatible - Eg. if partition was created with name having
+  // a special char that you want to start escaping, and then you try dropping
+  // the partition with a hive version that now escapes the special char using
+  // the list below, then the drop partition fails to work.
+
   static BitSet charToEscape = new BitSet(128);
   static {
     for (char c = 0; c < ' '; c++) {
@@ -144,9 +152,19 @@
public static String makePartName(List<String> partCols, List<String> vals,
         '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
         '"', '#', '%', '\'', '*', '/', ':', '=', '?', '\\', '\u007F', '{',
         '[', ']', '^'};
+
     for (char c : clist) {
       charToEscape.set(c);
     }
+    
+    if(Shell.WINDOWS){
+      //On windows, following chars need to be escaped as well
+      char [] winClist = {' ', '<','>','|'};
+      for (char c : winClist) {
+        charToEscape.set(c);
+      }
+    }
+
   }
 
   static boolean needsEscaping(char c) {
